<template>
	<view class="home">
		<view class="content">
			<div class="row" v-for="item in listArr" :key="item.index">
			<workOrderListCard :item="item" @click.native="goDetail(item)"></workOrderListCard>
			</div>
		</view>
		<view class="loading" v-if="listArr.length">
			<view v-if="loading==1">数据加载中...</view>
			<view v-if="loading==2">没有更多了...</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.getList()
		},
		onShow() {
			this.getList()
		},
		onBackPress(){
			this.destroy()
		},
		onPullDownRefresh(){
			console.log('页面下拉刷新了');
			this.getList()
		},
		onReachBottom() {  //触底
			console.log('到底部了');
			this.loading=1;
			this.getList()
		},
		data() {
			return {
				options:null,
				listArr:[],
				loading:0//0默认 1加载中 2没有更多了
			};
		},
		methods:{
			getList(){
				var data = uni.getStorageSync('reportInfoReal')//取出缓存数据
				var res = JSON.parse(data)
				this.listArr = res
				console.log(data);
				console.log(res)
				console.log(this.listArr)
				this.loading=2
			},
			destroy(){
				this.listArr=[]
				uni.removeStorageSync('reportInfoReal')
				var data = uni.getStorageSync('reportInfoReal')//销毁缓存数据
				console.log(data);
				console.log(this.listArr)
			},
			goDetail(item){
				let itemSingle = JSON.stringify(item)
				uni.setStorageSync('itemSingle',itemSingle)
				uni.navigateTo({
					url:'/pages/detailReal/detailReal'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.home{
	.content{
		padding: 20rpx;
		.row{
			border-bottom: 1px dotted #efefef;
			padding: 20rpx 0;
			
		}
	}
	.loading{
		text-align: center;
		font-size: 26rpx;
		color: #888;
		line-height: 1em;
	}
}
</style>
